﻿CREATE PROCEDURE [dbo].[proc_Order_Getlist_Cus_20141110]
	(
		@CusId varchar(60),
		@startIndex int,
		@endIndex int
	)
AS
Begin
	--成单记录
	;WITH List2 As(Select ROW_NUMBER() OVER (Order By id Desc) AS Row,OId,
		OrderId,Salesman,YingShouPrice,ShiShouPrice,CreateDate
		From [Order]
		Where CusId=@CusId And StateId>1
	)
	Select *,
	(Select Count(0) From List2) As RecordCount,
	(Select Sum(YingShouPrice) From List2) As OrderAmount
	From List2
	Where Row Between @startIndex And @endIndex
	Order By Row
End
